var express = require('express');
var router = express.Router();

const {
    addParkings,
    getParkings,
    deleteParkings,
    getParkingsId,
    updateParkings
} = require('../service/parkingsService')

router.post('/addParkings', async function (req, res, next) {
    console.log(req.body)
    const parking = req.body
    // console.log(11111, a);
    const data = await addParkings(parking)
    res.send(data)

});

router.get('/getParkings', async function (req, res, next) {
    console.log('第一层获取车位信息', req.query)
    const data = await getParkings(req.query)
    res.send(data)

});


// 删除

router.post('/deleteParkings', async function (req, res, next) {
    const _id = req.body
    await deleteParkings(_id)
    res.send({
        message: "车位删除成功",
        status: 1
    })
});

//修改
router.get('/getParkingsId', async function (req, res, next) {
    // const {_id,name,age,gender}=req.body
    const _id = req.query
    res.send(
        await getParkingsId(_id))

});

//确认修改  
router.post('/updateParkings', async function (req, res, next) {
    const parkings = req.body
    // console.log(11111, parkings);
    const data = await updateParkings(parkings)
    res.send(data)

});


module.exports = router;
